/* 
 * @moduleName: TransFormRadioUtil.js
 * @Desc: 单选框渲染
 * @Author: djkloop 
 * @Date: 2017-11-30 11:38:06 
 * @Last Modified by: djkloop
 * @Last Modified time: 2017-12-12 02:12:51
 */
import React from 'react'
import {Radio} from 'antd'
import colUtil from './ColWrapperUtil'
const RadioGroup = Radio.Group

export default {
  transformRadio(field,type) {
    let _rules = field.dateRules && type === 'single' ? field.dateRules.rules : [];
    const options = [];
    field.options.forEach(v => {
      options.push(<Radio key={v.key} value={v.key}>{v.value}</Radio>)
    })
    return colUtil.colWrapper((getFieldDecorator, forUpdate) => getFieldDecorator(field.key, {rules:_rules,initialValue: forUpdate ? undefined : field.defaultValue})(
      <RadioGroup>
        {
          options
        }
      </RadioGroup>
    ), field)
  }
}

